package main

import (
	"os"

	"gitee.com/kobeyyf/apibox/api"
	log "gitee.com/kobeyyf/apibox/logger"
)

var (
	logger *log.Logger
)

func main() {
	app, err := NewAPI()
	if err != nil {
		logger.Errorln("new api failed:", err.Error())
		os.Exit(-1)
	}
	err = app.Run()
	if err != nil {
		logger.Errorln(err)
		os.Exit(-1)
	}
	return
}

func NewAPI() (app *api.Api, err error) {
	app, err = api.NewAPI("./config.yaml")
	if err != nil {
		return nil, err
	}
	logger = app.GetLogger()
	app.AddHandles(Handles)

	return app, nil

}
